#pragma once
#include <dsound.h>
#include "SDKsound.h"
#include "SDKwavefile.h"

#define NUM_PLAY_NOTIFICATIONS  16
//#define SAFE_DELETE(p)  { if(p) { delete (p);     (p)=NULL; } }
//#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }

class WPENGIN_API CStreamingSoundPlayer
{
	friend DWORD WINAPI NotificationProcedure( LPVOID lpParameter );

public:
	CStreamingSoundPlayer(CSoundManager*  pSoundManger,TCHAR* strFileName,bool bPlayingBackGround = false,bool bLooped = true);
	~CStreamingSoundPlayer(void);
	void Stop();
	HRESULT Play( );
	bool IsPlaying();
private:
	bool OpenWave( TCHAR* strFileName ,bool bPlayingBackGround);
	CSoundManager*      m_pSoundManager         ;
	CStreamingSound*    m_pStreamingSound       ;
	HANDLE              m_hNotificationEvent    ;
	DWORD               m_dwNotifyThreadID      ;
	HANDLE              m_hNotifyThread         ;
	bool m_bLooped;
 
};
